package com.anolesoft.amljmes.fortysix.controller;

import com.anolesoft.amljmes.fortysix.dto.MesBzzBindDto;
import com.anolesoft.amljmes.fortysix.dto.MesBzzZcbldDto;
import com.anolesoft.amljmes.fortysix.service.info.MesBzzZcbldInfoService;
import com.anolesoft.common.core.constant.HttpStatus;
import com.anolesoft.common.core.domain.LoginUser;
import com.anolesoft.common.core.web.domain.AjaxResult;
import com.anolesoft.common.security.util.SecurityUtils;
import com.anolesoft.yr.demo.BaseQueryParamVO;
import com.anolesoft.yr.demo.PageResult;
import com.anolesoft.yr.util.Constants;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("mesbzzZcbld")
public class MesBzzZcbldInfoController {
    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @SuperBuilder
    @ToString(callSuper = true)
    @EqualsAndHashCode(callSuper=true)
    public static class DemoVO extends BaseQueryParamVO implements Serializable {
        private String baoliudanhao; // 保留单号
        private String supportingOrderNo; // 配套单号
        private String orderNumber; // 订单编号
        private String factoryCode; // 厂代号
    }

    @Autowired
    MesBzzZcbldInfoService mesBzzZcbldInfoService;
//
//    // 保留单页面查询
//    @PostMapping(value="/query",produces = MediaType.APPLICATION_JSON_VALUE)
//    @ResponseBody
//    public AjaxResult queryMesBzzZcbldInfo(MesBzzZcbldInfoController.DemoVO demoVO){
//        LoginUser loginUser = SecurityUtils.getLoginUser();
//        demoVO.setFactoryCode(loginUser.getFacCode());
//
//        List<MesBzzZcbldDto> allList = mesBzzZcbldInfoService.queryMesBzzZcbldInfo(demoVO);
//        System.out.println(">>>>>>"+allList.toString());
//        int pn =  demoVO.getPageNo().intValue();
//        int ps = demoVO.getPageSize().intValue();
//        int endIndex = pn * ps > allList.size() ? allList.size() : pn*ps;
//        List<MesBzzZcbldDto> list = allList.subList( (pn-1) *ps, endIndex  );
//        PageResult pageResult = new PageResult(list, demoVO.getPageSize(), demoVO.getPageNo(), allList.size());
//        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE,pageResult);
//    }
//
//    // 实物信息显示
//    @PostMapping(value="/all",produces = MediaType.APPLICATION_JSON_VALUE)
//    @ResponseBody
//    public AjaxResult queryPtdBind(String supportingOrderNo){
//        List<MesBzzBindDto> list = mesBzzZcbldInfoService.queryPtdBind(supportingOrderNo);
//        AjaxResult success = AjaxResult.success();
//        success.put("data", list);
//        return success;
//    }
//
//    //生成移交单号
//    @PostMapping(value="/updateYjdh", produces = MediaType.APPLICATION_JSON_VALUE)
//    public AjaxResult updateBindYjdh(@RequestBody String[] objuids){
//        System.out.println(">>>>>>update");
//        List<String> asList = null;
//        if (objuids != null) {
//            asList = Arrays.asList(objuids);
//        }
//        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE,mesBzzZcbldInfoService.updateBindYjdh(asList));
//    }
//
//    //生成补件单号
//    @PostMapping(value="/updateBjdh", produces = MediaType.APPLICATION_JSON_VALUE)
//    public AjaxResult updateBindBjdh(@RequestBody String[] objuids){
//        System.out.println(">>>>>>update");
//        List<String> asList = null;
//        if (objuids != null) {
//            asList = Arrays.asList(objuids);
//        }
//        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE,mesBzzZcbldInfoService.updateBindBjdh(asList));
//    }
//
//    // 配套单状态变为“已转场”
//    @PostMapping(value="/updatePtdStateZc", produces = MediaType.APPLICATION_JSON_VALUE)
//    public AjaxResult updatePtdStateZc(@RequestBody String[] objuids){
//        System.out.println(">>>>>>update");
//        List<String> asList = null;
//        if (objuids != null) {
//            asList = Arrays.asList(objuids);
//        }
//        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE,mesBzzZcbldInfoService.updatePtdStateZc(asList));
//    }
//
//    // 实物绑定状态变成“转场”
//    @PostMapping(value="/updateBindStateZc", produces = MediaType.APPLICATION_JSON_VALUE)
//    public AjaxResult updateBindStateZc(@RequestBody String[] ptdObjs){
//        System.out.println(">>>>>>update");
//        List<String> asList = null;
//        if (ptdObjs != null) {
//            asList = Arrays.asList(ptdObjs);
//        }
//        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE,mesBzzZcbldInfoService.updateBindStateZc(asList));
//    }
//
//    // 实物绑定状态变成“补件”
//    @PostMapping(value="/updateBindStateBj", produces = MediaType.APPLICATION_JSON_VALUE)
//    public AjaxResult updateBindStateBj(@RequestBody String[] ptdObjs){
//        System.out.println(">>>>>>update");
//        List<String> asList = null;
//        if (ptdObjs != null) {
//            asList = Arrays.asList(ptdObjs);
//        }
//        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE,mesBzzZcbldInfoService.updateBindStateBj(asList));
//    }
//
//    // 根据配套单条码查缺件数量不等于0的
//    @PostMapping(value="/qjs",produces = MediaType.APPLICATION_JSON_VALUE)
//    @ResponseBody
//    public AjaxResult queryPtdmxQjs(String peitaodanhao){
//        List<MesBzzBindDto> list = mesBzzZcbldInfoService.queryPtdmxQjs(peitaodanhao);
//        AjaxResult success = AjaxResult.success();
//        success.put("data", list);
//        return success;
//    }
//
//    // 生成转场保留单
//    @PostMapping(value="/add", produces = MediaType.APPLICATION_JSON_VALUE)
//    @ResponseBody
//    public AjaxResult addMesBzzZcbld(@RequestBody MesBzzZcbldDto inFoDtoParam){
//        System.out.println(">>>>>>add");
//        LoginUser loginUser = SecurityUtils.getLoginUser();
//        inFoDtoParam.setYijiaoren(loginUser.getEmpUid());
//        inFoDtoParam.setCreatName(loginUser.getEmpUid());
//        inFoDtoParam.setFactoryCode(loginUser.getFacCode());
//        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE,mesBzzZcbldInfoService.addMesBzzZcbld(inFoDtoParam));
//    }
}
